import java.util.*;

public class Test780 {
    public static void main(String[] args) {
        HashMap<String,Integer> map = new HashMap<>();
        map.put("1",1);
        map.put("2",2);
        map.put("3",3);
        map.put("4",4);
        for (String key : map.keySet()){
            System.out.println("key :"+key+" value:"+map.get(key));
        }
    }
    static List<String> list1 = new ArrayList<>();
    static List<String> list2 = new ArrayList<>();
    public static void main10(String[] args) {
        Scanner sc = new Scanner(System.in);
        int q = sc.nextInt();
        //一个代表操作1,一个代表操作2
        list1 = new ArrayList<>();
        list2 = new ArrayList<>();
        while(q > 0 ){
            q--;
            int op = sc.nextInt();
            String str = "";
//            StringBuffer s = new StringBuffer();
            int n = 2;
            while(n > 0){

                str = sc.nextLine();
//                break;
                n--;
            }

            func(op,str);
        }
    }
    static void func(int op,String str){

        if(op == 1){
            String[] s = str.split("\\(");
            String[] s2 = s[0].split(" ");
            String s3 = s2[1];
            if(list1.contains(s3)){
                System.out.println("method "+s3 +" is already defined.");
            } else{
                list1.add(str);
                System.out.println("ok");
            }
        } else {
            if(list1.contains(str)) {
                System.out.println("ok");
            } else{
                String[] s = str.split(" ");
                String[] s2 = s[0].split("\\(");
                String s3 = s2[0];
                if(s.length == 1) {
                    System.out.println("method "+s3+" cannot be applied to given types.");
                    return ;
                }else{
                    s = str.split("\\(");
                    s2 = s[0].split(" ");
                    s3 = s2[1];
                    if(list1.contains(s3)){
                        System.out.println("ok");
                    }else{
                        System.out.println("method "+s3+" cannot be applied to given types.");
                    }
                }

            }

        }

    }
}
